<?php
include_once "ConnectionManager.php";

function findAll(){
	$query = "SELECT * FROM GIAAN_BANNER";
	ConnectionManager::getInstance()->setQuery($query);
    return ConnectionManager::getInstance()->query();
}

function findBannerId($bannerId){
	$query = "SELECT BANNER_PATH FROM GIAAN_BANNER WHERE BANNER_ID = $bannerId";
	ConnectionManager::getInstance()->setQuery($query);
	$result = ConnectionManager::getInstance()->query();
	$row = ConnectionManager::getInstance()->fetch($result);
    return $row["BANNER_PATH"];
}

function insertBanner($bannerPath){
	$query = "INSERT INTO GIAAN_BANNER (BANNER_PATH) VALUES ('$bannerPath')";
	ConnectionManager::getInstance()->setQuery($query);
    return ConnectionManager::getInstance()->query();
}

function editBanner($bannerId, $newBannerPath){
	$query = "UPDATE GIAAN_BANNER SET BANNER_PATH = '$newBannerPath' WHERE BANNER_ID = $bannerId";
	ConnectionManager::getInstance()->setQuery($query);
    return ConnectionManager::getInstance()->query();
}

function deleteBanner($bannerId){
	$query = "DELETE FROM GIAAN_BANNER WHERE BANNER_ID = $bannerId";
	ConnectionManager::getInstance()->setQuery($query);
    return ConnectionManager::getInstance()->query();	
}
?>